package com.dk.service.impl;
import com.dk.pojo.Comment;
import com.dk.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private MongoTemplate mongoTemplate;

    //添加留言
    @Override
    public Comment saveMassage(Comment comment) {
        return mongoTemplate.save(comment);
    }

    //展示留言
    @Override
    public List<Comment> getMessage(Long carId) {
        Query query = new Query(Criteria.where("carId").is(carId));
        List<Comment> comments = mongoTemplate.find(query, Comment.class);
        return comments;
    }
}
